package com.cbi.clickhouse.JDKproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author Ivan.Qu reviewcode@163.com
 * @date 3:57 下午 2022/8/17
 */
public class TargetProxy implements InvocationHandler {
    UserServiceImpl userService = new UserServiceImpl();

    public <T> Object getProxy(Class<T> clazz) {return Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]{clazz}, this);}

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        return userService.nameList();
    }
}
